<layout name="Admin@default/common/dashboard_layout" />
<taglib name="Common\TagLib\Gy" />

<!-- Content Header (Page header) -->
<section class="content-header clearfix">
    <h1 class="pull-left">钩子列表</h1>
    <div class="pull-right">
        <Gy:auth node="admin.hooks.add"><a href="{:U('Hooks/add')}" class="btn btn-primary btn-sm"><i class="icon icon-plus"></i>  新增钩子</a></gy:auth>
    </div>
</section>
<!-- Main content -->
<section class="content" n-id="122">
    <div class="row mb-20">
        <div class="col-md-5">
            <div class="form-inline">
                <if condition="($map.status eq 1)">
                    <Gy:auth node="admin.hooks.forbid"><button data-msg-title="提示" data-msg-content="是否禁用所选择的内容？" data-msg-buttons="yes,no"  class="btn btn-danger btn-sm btn-list-disable"><i class="icon icon-forbid"></i> 禁用</button></Gy:auth>
                    <elseif condition="($map.status eq 0)"/>
                    <Gy:auth node="admin.hooks.resume"><button data-msg-title="提示" data-msg-content="是否启用所选择的内容？" data-msg-buttons="yes,no"  class="btn btn-primary btn-sm btn-list-enable"><i class="icon icon-plus"></i> 启用</button></Gy:auth>
                </if>
                <Gy:auth node="admin.hooks.delete"><button data-msg-title="提示" data-msg-content="是否删除所选择的内容？" data-msg-buttons="yes,no" class="btn btn-danger btn-sm btn-list-del"><i class="glyphicon glyphicon-remove"></i> 删除</button></Gy:auth>
            </div>
        </div>
    </div>
    <div class="box box-solid">
        <div class="box-body no-padding">
            <div class="nav-tabs-custom">
                <ul class="nav nav-tabs">
                    <volist name="statusList" id="vo">
                        <if condition="($map.status eq $vo[id])">
                            <li class='active'><a href="#">{$vo.name}</a></li>
                            <else />
                            <li><a href="__URL__/index/status/{$vo.id}">{$vo.name}</a></li>
                        </if>
                    </volist>
                </ul>
                <div class="tab-content no-padding mt-10">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th width="35"><input type="checkbox" name="menulist" data-fun="check-all-or-none" data-target="group-of-checkbox"></th>
                                <th>名称</th>
                                <th>描述</th>
                                <th>挂载规则</th>
                                <th width="160">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <volist name="list" id="hooks">
                                <tr>
                                    <th><input type="checkbox" name="menulist" data-group="table-group" data-target="group-of-checkbox" value="{$hooks.id}"></th>
                                    <td>{$hooks.name}</td>
                                    <td>{$hooks.desc}</td>
                                    <td>{$hooks.rule}</td>
                                    <td>
                                        <Gy:auth node="admin.hooks.edit"><a href="__URL__/edit/id/{$hooks.id}" class="btn btn-primary btn-xs">编辑</a></gy:auth>
                                        <if condition="($hooks.status eq 1)">
                                            <Gy:auth node="admin.hooks.forbid"><a href="__URL__/forbid/id/{$hooks.id}" class="btn btn-primary btn-xs ajax-submit">禁用</a></gy:auth>
                                            <else />
                                            <Gy:auth node="admin.hooks.resume"><a href="__URL__/resume/id/{$hooks.id}" class="btn btn-primary btn-xs ajax-submit">启用</a></gy:auth>
                                        </if>
                                        <Gy:auth node="admin.hooks.delete"><a href="__URL__/delete/id/{$hooks.id}" class="btn btn-danger btn-xs ajax-submit">删除</a></gy:auth>
                                    </td>
                                </td>
                            </tr>
                        </volist>
                    </tbody>
                </table>
            </div><!-- /.tab-content -->
        </div>
    </div><!-- /.box-body -->
</div><!-- /.box -->
<div class="row">
    <div class="col-md-5">
        <div class="form-inline">
            <if condition="($map.status eq 1)">
                    <Gy:auth node="admin.hooks.forbid"><button data-msg-title="提示" data-msg-content="是否禁用所选择的内容？" data-msg-buttons="yes,no"  class="btn btn-danger btn-sm btn-list-disable"><i class="icon icon-forbid"></i> 禁用</button></Gy:auth>
                    <elseif condition="($map.status eq 0)"/>
                    <Gy:auth node="admin.hooks.resume"><button data-msg-title="提示" data-msg-content="是否启用所选择的内容？" data-msg-buttons="yes,no"  class="btn btn-primary btn-sm btn-list-enable"><i class="icon icon-plus"></i> 启用</button></gy:auth>
                </if>
                <Gy:auth node="admin.hooks.delete"><button data-msg-title="提示" data-msg-content="是否删除所选择的内容？" data-msg-buttons="yes,no" class="btn btn-danger btn-sm btn-list-del"><i class="glyphicon glyphicon-remove"></i> 删除</button></Gy:auth>
        </div>
    </div>
    <div class="col-md-7">
        <div class="pull-right">
            <include file="common/pagination" />
        </div>
    </div>
</div>
</section><!-- /.content -->

@section:script{%
<script type="text/javascript" src="__PUBLIC__/libs/jquery.group-of-checkbox/jquery.group-of-checkbox.js"></script>
<script type="text/javascript" src="__PUBLIC__/libs/bootstrap-messagebox/bootstrap-messagebox.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($){

   $('.btn-list-disable').bs_messagebox({success:function(status){
      if(status=="cancel") return;
      if(status=="yes"){
        var checkboxGroup = $('[data-target=group-of-checkbox]').data('checkboxGroup');
        ajaxlink($(this),"__URL__/forbid/id/" + checkboxGroup.getCheckedValue());

        //location.href = "__URL__/forbid/id/" + checkboxGroup.getCheckedValue();
    }
}});
   $('.btn-list-enable').bs_messagebox({success:function(status){
      if(status=="cancel") return;
      if(status=="yes"){
         var checkboxGroup = $('[data-target=group-of-checkbox]').data('checkboxGroup');
         ajaxlink($(this),"__URL__/resume/id/" + checkboxGroup.getCheckedValue());
         //location.href = "__URL__/resume/id/" + checkboxGroup.getCheckedValue();
     }
 }});
   $('.btn-list-del').bs_messagebox({success:function(status){
      if(status=="cancel") return;
      if(status=="yes"){
         var checkboxGroup = $('[data-target=group-of-checkbox]').data('checkboxGroup');
         ajaxlink($(this),"__URL__/delete/id/" + checkboxGroup.getCheckedValue());
         //location.href = "__URL__/delete/id/" + checkboxGroup.getCheckedValue();
     }
 }});
});
</script>
%}
